// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   OrderChangeAction.java

package com.boci.clientapp.orderstatus.action;

import com.boci.clientapp.main.ApplicationService;
import com.boci.clientapp.main.MainPanel;
import com.boci.clientapp.orderstatus.*;
import com.boci.clientapp.orderstatus.handler.OrderChangeConfirmHandler;
import com.boci.clientapp.orderstatus.handler.OrderChangeReviewHandler;
import com.boci.clientapp.orderstatus.vo.*;
import com.boci.common.action.AbstractAction;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.ui.AbstractTabSclPane;
import com.boci.common.util.AppException;
import com.boci.common.util.StringUtil;
import com.boci.common.vo.ResponseVO;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.Logger;

public class OrderChangeAction extends AbstractAction
{

    public OrderChangeAction()
    {
        strModName = "ORDER_STATUS_MODULE";
    }

    public void doProcess(HashMap pInpMap, String pActionType)
    {
    	try{
	        appServ.setBusy(true);
	        if(pActionType.equals("CHANGE_EDIT_REVIEW"))
	            doOrderChangeReview(pInpMap);
	        else
	        if(pActionType.equals("BACK_TO_ORDER_STATUS"))
	        {
	            String strOrderStatusScr = "ORDER_STATUS_SCREEN";
	            appServ.getMainPanel().showScreen(strModName, strOrderStatusScr, false);
	        } else
	        if(pActionType.equals("BACK_TO_ORDER_CHANGE_EDIT"))
	        {
	            String strOrderChangeEditScr = "ORDER_STATUS_CHANGE_EDIT";
	            appServ.getMainPanel().showScreen(strModName, strOrderChangeEditScr);
	            OrderChangeEditScrPanel orderChangeEditScrPanel = (OrderChangeEditScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderChangeEditScr);
	            orderChangeEditScrPanel.refresh(pInpMap);
	        } else
	        if(pActionType.equals("CHANGE_REVIEW_CONFIRM"))
	            doOrderChangeConfirm(pInpMap);
	        else
	        if(pActionType.equals("CHANGE_REVIEW_CANCEL"))
	        {
	            String strOrderStatusScr = "ORDER_STATUS_SCREEN";
	            appServ.getMainPanel().showScreen(strModName, strOrderStatusScr, false);
	        } else
	        if(pActionType.equals("CHANGE_CONFIRM_OK"))
	        {
	            String strOrderStatusScr = "ORDER_STATUS_SCREEN";
	            OrderStatusScrPanel orderStatusPanel = (OrderStatusScrPanel)appServ.getMainPanel().getTab(strModName).getPanel(strOrderStatusScr);
	            int intLastSelection = orderStatusPanel.getSelection();
	            appServ.getMainPanel().showScreen(strModName, strOrderStatusScr);
	            orderStatusPanel.showOrderStatusTable(intLastSelection);
	        }
    	}
        catch(AppException appEx)
        {
            appServ.showErrorDialog(null, appEx.getMessage());
        }
        catch(Exception sysEx)
        {
            logger.severe(StringUtil.formatException(sysEx));
            appServ.showSysErrDialog();
        }
        finally
        {
            appServ.setBusy(false);
        }
        return;
    }

    private void doOrderChangeReview(HashMap pInpMap)
        throws Exception
    {
        String strReqType = RequestTypeConst.BOCI_ORDER_CHG_REVW_URL;
        String strOrderChangeReviewScr = "ORDER_STATUS_CHANGE_REVIEW";
        ResponseVO responseVO = (ResponseVO)pInpMap.get("SELECTED_VO");
        String strNewQty = (String)pInpMap.get("NEW_QTY");
        String strNewPrice = (String)pInpMap.get("NEW_PRICE");
        if(responseVO == null)
            return;
        OrderStatusDetailVO orderStatusDetailVO = null;
        if(responseVO instanceof OrderStatusDetailVO)
            orderStatusDetailVO = (OrderStatusDetailVO)responseVO;
        else
            return;
        HashMap inHashMap = new HashMap();
        inHashMap.put("orderreview2", "Review Before Sending");
        inHashMap.put("newQnty", strNewQty);
        inHashMap.put("newPrice", strNewPrice);
        inHashMap.put("orderId", orderStatusDetailVO.getOrderId());
        inHashMap.put("str", "REVIEW");
        OrderChangeReviewHandler orderChangeReviewHandler = new OrderChangeReviewHandler(strReqType);
        OrderChangeReviewVO orderChangeReviewVO = (OrderChangeReviewVO)orderChangeReviewHandler.getOrderChangeReview(inHashMap);
        appServ.getMainPanel().showScreen(strModName, strOrderChangeReviewScr);
        OrderChangeReviewScrPanel orderChangeReviewScrPanel = (OrderChangeReviewScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderChangeReviewScr);
        pInpMap.put("ORDER_CHANGE_REVIEW_VO", orderChangeReviewVO);
        orderChangeReviewScrPanel.refresh(pInpMap);
    }

    private void doOrderChangeConfirm(HashMap pInpMap)
        throws Exception
    {
        String strReqType = RequestTypeConst.BOCI_ORDER_CHG_SEND_URL;
        String strOrderChangeConfirmScr = "ORDER_STATUS_CHANGE_CONFIRM";
        String strOrderStatusScr = "ORDER_STATUS_SCREEN";
        ResponseVO responseVO = (ResponseVO)pInpMap.get("SELECTED_VO");
        OrderChangeReviewVO orderChangeReviewVO = (OrderChangeReviewVO)pInpMap.get("ORDER_CHANGE_REVIEW_VO");
        String strNewQty = (String)pInpMap.get("NEW_QTY");
        String strNewPrice = (String)pInpMap.get("NEW_PRICE");
        if(responseVO == null)
            return;
        OrderStatusDetailVO orderStatusDetailVO = null;
        if(responseVO instanceof OrderStatusDetailVO)
            orderStatusDetailVO = (OrderStatusDetailVO)responseVO;
        else
            return;
        HashMap inHashMap = new HashMap();
        inHashMap.put("sendValue", "Send Order");
        inHashMap.put("newQnty", strNewQty);
        inHashMap.put("newPrice", strNewPrice);
        inHashMap.put("orderId", orderChangeReviewVO.getOrderId());
        OrderChangeConfirmHandler orderChangeConfirmHandler = new OrderChangeConfirmHandler(strReqType);
        OrderChangeConfirmVO orderChangeConfirmVO = (OrderChangeConfirmVO)orderChangeConfirmHandler.getOrderChangeConfirm(inHashMap);
        OrderStatusScrPanel orderStatusScrPanel = (OrderStatusScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderStatusScr);
        orderStatusScrPanel.setLastUpdateDateTime(new Date());
        orderStatusScrPanel.updateAllLastUpdateTime();
        appServ.getMainPanel().showScreen(strModName, strOrderChangeConfirmScr);
        OrderChangeConfirmScrPanel orderChangeConfirmScrPanel = (OrderChangeConfirmScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderChangeConfirmScr);
        orderChangeConfirmScrPanel.refresh(pInpMap);
    }

    String strModName;
}
